/**
 * Created With IntelliJ IDEA
 * Description:leetcode：226. 翻转二叉树
 * <a href="https://leetcode.cn/problems/invert-binary-tree/">...</a>
 * User: DELL
 * Data: 2023-01-14
 * Time: 11:43
 */

class TreeNode {
    int val;
    TreeNode left;
    TreeNode right;
    public TreeNode(int val) {
        this.val = val;
    }
}
public class Solution {
    public TreeNode invertTree(TreeNode root) {
        if (root == null) {
            return null;
        }
        TreeNode leftTree = invertTree(root.right);
        TreeNode rightTree = invertTree(root.left);
        root.left = leftTree;
        root.right = rightTree;
        return root;
    }
}